import { AllLogin } from '../actions/action'

interface IState {
  token: string
  userInfo: any
}

const initialState: IState = {
  token: '',
  userInfo: {}
}

const loginReducer = (state = initialState, action: AllLogin) => {
  switch (action.type) {
    case 'LOGITN_SUCCESS':
      return { ...state, token: action.payload }

    case 'USERINFO_SUCCESS':
      return { ...state, userInfo: action.payload }

    default:
      return state
  }
}

export default loginReducer
